package com.ecoolex.chinadutyfree.retailer.ws;

import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.chinadutyfree.retailer.core.manager.DeliveryMannerManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.FreightTemplateChargingManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.FreightTemplateChargingRegionManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.FreightTemplateManager;
import com.ecoolex.chinadutyfree.retailer.entity.DeliveryManner;
import com.ecoolex.chinadutyfree.retailer.entity.FreightTemplate;
import com.ecoolex.chinadutyfree.retailer.entity.FreightTemplateCharging;
import com.ecoolex.chinadutyfree.retailer.entity.FreightTemplateChargingRegion;
import com.ecoolex.chinadutyfree.retailer.pojo.EditFreightTemplateChargingDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.QueryFreightTemplateDTO;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;

@Service
public class DeliveryServiceImpl implements DeliveryService {

	@Autowired
	private DeliveryMannerManager deliveryMannerManager;

	@Override
	public DeliveryManner addDeliveryManner(DeliveryManner record, String createUser) {
		return deliveryMannerManager.add(record, createUser);
	}

	@Override
	public DeliveryManner updateDeliveryManner(DeliveryManner record, String updateUser) {
		return deliveryMannerManager.update(record, updateUser);
	}

	@Override
	public void deleteDeliveryManner(DeliveryManner record, String updateUser) {
		deliveryMannerManager.delete(record, updateUser);
	}

	@Override
	public DeliveryManner getDeliveryMannerById(Integer deliveryMannerId) {
		return deliveryMannerManager.getById(deliveryMannerId);
	}

	@Override
	public Pagination<DeliveryManner> queryDeliveryManner(String name, Sorting[] sorts, Page page) {
		return deliveryMannerManager.query(name, sorts, page);
	}
	
	@Override
	public List<DeliveryManner> queryDeliveryMannerByUserShoppingCartIds(Integer userId, List<Integer> cartIds) {
		return deliveryMannerManager.queryByUserShoppingCartIds(userId, cartIds);
	}

	@Autowired
	private FreightTemplateManager freightTemplateManager;

	@Override
	public FreightTemplate addFreightTemplate(FreightTemplate record, List<EditFreightTemplateChargingDTO> chargingList, String createUser) {
		return freightTemplateManager.add(record, chargingList, createUser);
	}

	@Override
	public FreightTemplate editFreightTemplate(FreightTemplate record, List<EditFreightTemplateChargingDTO> chargingList, String updateUser) {
		return freightTemplateManager.edit(record, chargingList, updateUser);
	}

	@Override
	public void deleteFreightTemplate(FreightTemplate record, String updateUser) {
		freightTemplateManager.delete(record, updateUser);
	}

	@Override
	public FreightTemplate getFreightTemplateById(Integer freightTemplateId) {
		return freightTemplateManager.getById(freightTemplateId);
	}

	@Override
	public Pagination<FreightTemplate> queryFreightTemplate(QueryFreightTemplateDTO query, Sorting[] sorts, Page page) {
		return freightTemplateManager.query(query, sorts, page);
	}

	@Autowired
	private FreightTemplateChargingManager freightTemplateChargingManager;

	@Override
	public List<FreightTemplateCharging> queryFreightTemplateChargingByFreightTemplateId(Integer freightTemplateId) {
		return freightTemplateChargingManager.queryByFreightTemplateId(freightTemplateId);
	}

	@Autowired
	private FreightTemplateChargingRegionManager freightTemplateChargingRegionManager;

	@Override
	public long countFreightTemplateChargingRegionByChargingId(Integer chargingId) {
		return freightTemplateChargingRegionManager.countByChargingId(chargingId);
	}

	@Override
	public List<FreightTemplateChargingRegion> queryFreightTemplateChargingRegionByChargingId(Integer chargingId, Integer size) {
		return freightTemplateChargingRegionManager.queryByChargingId(chargingId, size);
	}
}
